You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The removal of the check enforcing benchmarks_root as a subdirectory of tests_root could lead to unexpected file path handling. Ensure downstream operations correctly support benchmark roots outside the tests directory.
assertPath(args.module_root).is_dir(), f"--module-root {args.module_root} must be a valid directory"assertargs.tests_rootisnotNone, "--tests-root must be specified"assertPath(args.tests_root).is_dir(), f"--tests-root {args.tests_root} must be a valid directory"ifargs.benchmark:
assertargs.benchmarks_rootisnotNone, "--benchmarks-root must be specified when running with --benchmark"assertPath(args.benchmarks_root).is_dir(), (
f"--benchmarks-root {args.benchmarks_root} must be a valid directory"
)
tempfile.mkdtemp creates a new replay tests directory under tests_root but no cleanup mechanism is shown. Confirm whether these directories should be removed after use to avoid resource leaks.
Reinstate the check ensuring that benchmarks_root is within tests_root to prevent misconfiguration and unexpected file writes. This safeguards that benchmarks run only inside the designated tests directory.
if args.benchmark:
assert args.benchmarks_root is not None, "--benchmarks-root must be specified when running with --benchmark"
assert Path(args.benchmarks_root).is_dir(), (
f"--benchmarks-root {args.benchmarks_root} must be a valid directory"
)
+ assert Path(args.benchmarks_root).resolve().is_relative_to(Path(args.tests_root).resolve()), (+ f"--benchmarks-root {args.benchmarks_root} must be a subdirectory of --tests-root {args.tests_root}"+ )
if env_utils.get_pr_number() is not None:
Suggestion importance[1-10]: 7
__
Why: The reinstated is_relative_to assertion correctly enforces that benchmarks_root is a subdirectory of tests_root, preventing misconfiguration and unintended file writes.
Medium
General
Resolve tests_root before mkdtemp
Resolve tests_root to an absolute path before passing it to mkdtemp to avoid creating directories in unexpected locations when relative paths are used.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Type
Bug fix, Enhancement
Description
Relax
--benchmarks-rootsubdirectory requirementCreate replay tests under
tests_rootdirectoryChanges walkthrough 📝
cli.py
Remove benchmarks_root subdir assertioncodeflash/cli_cmds/cli.py
benchmarks_rootundertests_rootoptimizer.py
Save replay tests under tests_rootcodeflash/optimization/optimizer.py
tempfile.mkdtempdirectory to usetests_root